﻿#include "StringSelectEditEntry.h"
#include <QComboBox>

struct StringSelectEditEntry::StringSelectEditEntryPrivate {
    QPointer<QComboBox> combobox;
};

StringSelectEditEntry::~StringSelectEditEntry() { }

StringSelectEditEntry::StringSelectEditEntry(QWidget *parent) : EditEntry {parent} {
    p.reset(new StringSelectEditEntryPrivate);
    initUi();
}

void StringSelectEditEntry::setStringList(const QStringList &list) {
    for(const auto &item : list) {
        p->combobox->addItem(item);
    }
}

void StringSelectEditEntry::setValue(const QString &value) {
    p->combobox->setCurrentText(value);
}

QString StringSelectEditEntry::value() const {
    return p->combobox->currentText();
}

void StringSelectEditEntry::initUi() {
    p->combobox = new QComboBox;
    addEditControll(p->combobox);
}
